package com.example.audiostreaming.adapters;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.audiostreaming.base.BaseFragment;
import com.example.audiostreaming.utils.UtilConstants;
import com.example.audiostreaming.utils.UtilFragmentCreator;

/**
 * MainViewPager主视图页面的适配器
 */
public class AdapterMainViewPager extends FragmentPagerAdapter {

    public AdapterMainViewPager(@NonNull FragmentManager fm) {
        super(fm);
    }

    /**
     * 返回获取MainViewPager主视图页面的Fragment片段
     *
     * @param position
     * @return
     */
    @NonNull
    @Override
    public Fragment getItem(int position) {
        BaseFragment fragment = UtilFragmentCreator.getFragment(position);
        return fragment;
    }

    /**
     * 返回获取MainViewPager主视图页面个数
     *
     * @return
     */
    @Override
    public int getCount() {
        return UtilConstants.COUNT_PAGE;
    }
}
